<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>游客信息列表</title>
</head>
<body>
	<a href="AccountServlet?method=logout">退出登录</a>
	<form action="TouristServlet?method=touristList">
	<input type="button" id="insert" name="insert" onclick="location.href='tourist_insert.jsp'" value="添加游客信息">
	</form>
	<table border="1">
		<tr>
			<th>编号</th>
			<th>姓名</th>
			<th>性别</th>
			<th>年龄</th>
			<th>身份证号码</th>
			<th>手机号码</th>
			<th>注册时间</th>
			<th>操作</th>
		</tr>
		<c:forEach items="${pageInfo.list }" var="tourist">
		<tr>
			<td>${tourist.id }</td>
			<td>${tourist.name }</td>
			<td>${tourist.sex }</td>
			<td>${tourist.age }</td>
			<td>${tourist.id_number }</td>
			<td>${tourist.phone_number }</td>
			<td><fmt:formatDate value="${tourist.created_time }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
			<td>
			<a href="javascript:confirmDelete(${tourist.id })">删除</a>
			<a href="TouristServlet?method=touristUpdate&id=${tourist.id }">修改</a>
			</td>
		</tr>
		</c:forEach>
	</table>
	<table>
		<tr>
			<td>
			总计${pageInfo.total}条记录，每页${pageInfo.pageSize}条数据 共${pageInfo.pages}页 当前第${pageInfo.pageNum}页
			<a href="TouristServlet?pageNum=1">首页</a>
			<c:if test="${not pageInfo.isFirstPage}">
			<a href="TouristServlet?pageNum=${pageInfo.prePage}">上一页</a>
			</c:if> 
			<c:if test="${pageInfo.isFirstPage}">上一页</c:if>
			<c:if test="${not pageInfo.isLastPage}">
			<a href="TouristServlet?pageNum=${pageInfo.nextPage}">下一页</a>
			</c:if>
			<c:if test="${pageInfo.isLastPage}">下一页</c:if>
			<a href="TouristServlet?pageNum=${pageInfo.pages}">尾页</a>
			</td>
		</tr>
	</table>
	<script>
	function confirmDelete(id){
		if(confirm("您确定要删除么？")){
			location.href = "TouristServlet?method=touristDelete&id="+id;
		}
	}
	</script>
</body>
</html>